#include <QtGui>
#include "openfilebutton.h"


OpenFileButton::OpenFileButton(QToolButton *button,QLineEdit *edit,const QString &filter)
{
	_edit   = edit;
	connect(button,SIGNAL(clicked()),SLOT(showFileDialog()));
	_filter = filter;
	_edit->setText(QSettings().value(_edit->objectName()).toString());	
}

void OpenFileButton::showFileDialog()
{
	QString fileName = QFileDialog::getOpenFileName(0,trUtf8("Открыть файл"),QSettings().value(_edit->objectName()).toString(),_filter);
	if(!fileName.isEmpty()){
		_edit->setText(fileName);
		QSettings().setValue(_edit->objectName(),fileName);
	}
}
